<?php
namespace App\Models\Eticket;
use App\Scopes\SchoolScope;
use Illuminate\Database\Eloquent\Model;
use App\Traits\ActionButtonAttributeTrait;
class Activity extends Model
{
	use ActionButtonAttributeTrait;

    const OPEN = 0;
    const CLOSE = 1;
    const CACHE_WRITEOFF = 'writeoff_';
    private $action = 'eticket/activity';

    protected $guarded = [];

    public function __construct(array $attributes = [])
    {
        parent::__construct($attributes);
    }

    //核销人员最大人数
    public static function cacheWriteOffMaxKey($id)
    {
        return self::CACHE_WRITEOFF . $id.'_max_number';
    }

    //核销人员二维码
    public static function cacheWriteOffQrcodeKey($id)
    {
        return self::CACHE_WRITEOFF . $id.'_qrcode';
    }

    //核销人员
    public static function cacheWriteOffUserKey($id)
    {
        return self::CACHE_WRITEOFF . $id.'_user';
    }

    /**
     * 数据模型的启动方法
     *
     * @return void
     */
    protected static function boot()
    {
        parent::boot();

        static::addGlobalScope(new SchoolScope);
    }

    public function schoolObj()
    {
        return $this->belongsTo('App\Models\School','school','name');
    }

    public function online()
    {
        return $this->hasOne('App\Models\Eticket\Online');
    }
    public function offline()
    {
        return $this->hasOne('App\Models\Eticket\Offline');
    }
}
